package cn.wolfcode.luowowo.mgrsite.controller;

import cn.wolfcode.luowowo.article.service.IDestinationService;
import cn.wolfcode.luowowo.common.query.DestinationQueryObject;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/destination")
public class DestinationController {
    @Reference
    private IDestinationService destinationService;

    @RequestMapping("/list")
    public String list(@ModelAttribute("qo") DestinationQueryObject qo, Model model) {
        if (qo.getDestId()!=null){
            if (qo.getParentId() > 0) { //当前不是顶级,查询面包屑
                //toasts
                model.addAttribute("toasts",
                        destinationService.listToasts(qo.getParentId()));
            }
        }

        model.addAttribute("pageInfo", destinationService.query(qo));
        return "destination/list";
    }
}
